define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'production_recipe_process/index' + location.search,
                    add_url: 'production_recipe_process/add',
                    edit_url: 'production_recipe_process/edit',
                    del_url: 'production_recipe_process/del',
                    multi_url: 'production_recipe_process/multi',
                    import_url: 'production_recipe_process/import',
                    table: 'production_recipe_process',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'process_name', title: __('Process_name'), operate: 'LIKE'},
                        {field: 'carrier_spec', title: __('Carrier_spec'), operate: 'LIKE'},
                        {field: 'production_speed', title: __('Production_speed'), operate:'BETWEEN'},
                        {field: 'unwinding_tension', title: __('Unwinding_tension'), operate:'BETWEEN'},
                        {field: 'injection_machine', title: __('Injection_machine'), operate: 'LIKE'},
                        {field: 'mixer_number', title: __('Mixer_number'), operate: 'LIKE'},
                        {field: 'mixing_plate_number', title: __('Mixing_plate_number'), operate: 'LIKE'},
                        {field: 'filter', title: __('Filter'), searchList: {"过滤网1号":__('过滤网1号'),"过滤网2号":__('过滤网2号')}, formatter: Table.api.formatter.normal},
                        {field: 'injection_hose', title: __('Injection_hose'), operate: 'LIKE'},
                        {field: 'static_mixer_size', title: __('Static_mixer_size'), operate: 'LIKE'},
                        {field: 'responsible_person', title: __('Responsible_person'), operate: 'LIKE'},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'status', title: __('Status')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
